package ssm.strategy;

public class Hand {
	public static final int HAND_CNT = 3;
	private final int VICTORY = 1;
	private final int DRAW = 0;
	private final int DEFEAT = -1;
	
	public static final int HANDVALUE_GUU = 0;
	public static final int HANDVALUE_CHO = 1;
	public static final int HANDVALUE_PAA = 2;
	public static final Hand[] hand = {
		new Hand(HANDVALUE_GUU),
		new Hand(HANDVALUE_CHO),
		new Hand(HANDVALUE_PAA),
	};
	private static final String[] name = {
		"주먹", "가위", "보"
	};
	private int handValue;
	public Hand(int handValue) {
		this.handValue = handValue;
	}
	public static Hand getHand(int handValue){
		return hand[handValue];
	}
	public boolean isStrongerThan(Hand h){
		return fight(h) == VICTORY;
	}
	public boolean isWeakerThan(Hand h){
		return fight(h) == DEFEAT;
	}
	private int fight(Hand h){
		if (this == h) {
			return DRAW;
		} else if ((this.handValue + 1) % 3 == h.handValue){
			return VICTORY;
		} else {
			return DEFEAT;
		}
	}
	public String toString(){
		return name[handValue];
	}
}
